
<template>
  <views class="facilitator_enterprise_sign">
    <viewTitle :title="'签约记录'" :border="false"></viewTitle>
    <!-- 搜索栏 服务商端 -->
    <div class="search flex flexC">
      <!-- 签约服务商-企业编号-企业状态-关键字-创建时间 -->
      <el-form ref="form" label-width="auto" :inline="true">
        <div class="search_input flex flexR center">
          <div class="bank_statement flex flexR center">
            <el-form-item label="企业编号:">
              <el-input v-model="form.enterprise_sn" placeholder="请输入企业编号" clearabled></el-input>
            </el-form-item>
          </div>

          <div class="bank_statement flex flexR center">
            <el-form-item label="企业名称:">
              <el-input v-model="form.enterprise_name" placeholder="请输入企业名称" clearabled></el-input>
            </el-form-item>
          </div>

          <div class="pay_state flex flexR center">
            <el-form-item label="企业状态:">
              <el-select v-model="form.enterprise_status" placeholder="请选择">
                <el-option
                  v-for="item in form.enterprise_state_list"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </div>

          <div class="keyword flex flexR center">
            <el-form-item label="关键字:">
              <el-input v-model="form.keys" placeholder="可输入姓名/手机/身份证/银行卡号" clearabled></el-input>
            </el-form-item>
          </div>
        </div>
      </el-form>
      <!--  按钮 (查询、重置、新增)-->
      <el-form ref="form" label-width="auto" :inline="true">
        <div class="pay_btn flex">
          <div class="pay_state flex flexR center">
            <el-form-item label="人员状态:">
              <el-select v-model="form.professional_status" placeholder="请选择">
                <el-option
                  v-for="item in form.professional_status_list"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </div>
          <div class="pay_time flex flexR center">
            <el-form-item label="创建时间:">
            <el-date-picker
              v-model="form.create_time"
              type="datetimerange"
              value-format="timestamp"
              :default-time="['0:00:00','23:59:59']"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            ></el-date-picker>
            </el-form-item>
          </div>
          <!-- 按钮（查询、重置、新增） -->
          <el-form-item >
          <div class="flex flexR pay_btn_list">
            <el-button type="primary" @click="query">查询</el-button>
            <el-button @click="reset">重置</el-button>
            <el-button type="warning" @click="exportList" icon="el-icon-download">导出列表</el-button>
          </div>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <!-- 展示列表 -->
    <div class="table_list">
      <el-table
        border
        :data="tableData"
        style="width: 100%;max-width:none;"
        :header-cell-style="getRowClass"
        :select-on-indeterminate="true"
        :fit="true"
        :lazy="true"
        @row-click="clickRow"
        max-height="450"
      >
        <el-table-column fixed="left" type="index" label="序号" width="100"></el-table-column>
        <el-table-column prop="enterprise_sn" label="企业编号" width="300"></el-table-column>
        <el-table-column prop="enterprise_name" label="企业名称" width="120"></el-table-column>
        <el-table-column prop="professional_sn" label="个人编号" width="300"></el-table-column>
        <el-table-column prop="professional_name" label="姓名" width="120"></el-table-column>
        <el-table-column prop="professional_cer_code" label="身份证" width="300"></el-table-column>
        <el-table-column prop="professional_bank_code" label="银行卡号" width="300"></el-table-column>
        <el-table-column prop="professional_mobile" label="预留手机" width="150"></el-table-column>
        <el-table-column prop="enterprise_professional_facilitator_sn" label="签约编号" width="300"></el-table-column>
        <el-table-column prop="p_contract_status" label="人员状态" width="150"></el-table-column>
        <el-table-column prop="contract_start_time" label="开始日期" width="200"></el-table-column>
        <el-table-column prop="contract_end_time" label="终止日期" width="200"></el-table-column>
        <el-table-column prop="created_time" label="创建时间" width="200"></el-table-column>
      </el-table>
      <div class="flex flexR paging">
        <el-pagination
          style="background:#fff; padding:10px 0"
          background
          layout="total, sizes,prev, pager, next, jumper"
          @size-change="handleSizeChange($event)"
          @current-change="changePage($event)"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="pagination.page_size"
          :total="pagination.total_count"
          :current-page="pagination.current_page"
          :page-count="pagination.page_count"
        ></el-pagination>
      </div>
    </div>
  </views>
</template>



<script>
export default {
  data() {
    return {
      //  三段综合  企业端  代理商端  服务商端
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },

      form: {
        enterprise_sn: "", // 企业编号
        keys: "", // 关键字
        enterprise_status: null, // 企业状态
        enterprise_state_list: [
          { value: null, label: "全部" },
          { value: 0, label: "待审核" },
          { value: 1, label: "正常" },
          { value: 2, label: "已冻结" },
          { value: 3, label: "审核不通过" }
        ],
        professional_status: null, //人员状态
        professional_status_list: [
          { value: null, label: "全部" },
          { value: 0, label: "未签约" },
          { value: 1, label: "已签约" },
          { value: 2, label: "已解约" }
        ], //人员状态列表 0：未签约、1：已签约、2：已解约
        create_time: [] // 创建时间
      },
      tableData: [],
      pagination: {
        //分页数据
        page_start: 0, //搜索开始页码
        current_page: 0, //当前页码
        page_count: 0, //总页数
        page_size: 10, //每页数量
        total_count: 0 //总数量
      }
    };
  },
  mounted() {
    this.query();
  },
  computed: {
    post_data() {
      let data = {};
      if (this.form.create_time && this.form.create_time.length > 0) {
        // data.professional_created_start_time = this.form.create_time[0] / 1000; //去掉后面的毫秒级
        // data.professional_created_end_time = this.form.create_time[1] / 1000; //去掉后面的毫秒级
        data.created_time_start = this.form.create_time[0]/1000;
        data.created_time_end = this.form.create_time[1]/1000;
      }
      data.enterprise_sn = this.form.enterprise_sn;
      data.enterprise_name = this.form.enterprise_name;
      if (this.form.enterprise_status !== null)
        data.enterprise_status = this.form.enterprise_status;
      if (this.form.professional_status !== null)
        data.professional_status = this.form.professional_status;
      data.pagination = this.pagination;
      data.keys = this.form.keys;
      return data;
    }
  },
  methods: {
    //    修改第一行样式
    getRowClass({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background: #FAFAFA ";
      } else {
        return "";
      }
    },
    //     点击单行
    clickRow(row, column, event) {
      console.log(row, column, event);
    },
    //    修改是否换行
    changeStyleRow(width) {
      let _width = width - 290 - 350 - 300 - 50 - 25;
      if (_width > 300) {
        this.marginLeft = 25;
      } else {
        this.marginLeft = 0;
      }
    },
    handleSizeChange(page_size) {
      //变动每页数量时
      this.pagination.page_size = page_size;
      this.query();
    },
    changePage(current_page) {
      //切换页码时
      this.pagination.page_start = current_page;
      this.query();
    },
    query() {
      let { code, msg, data } = this.$api.sendSync(
        this.$mapapi.f_getProfessionalList,
        this.post_data
      );
      if (code != 200 && code != 501) {
        this.$message.error(msg);
        this.tableData = [];
        this.pagination = {
          //分页数据
          page_start: 0, //搜索开始页码
          current_page: 0, //当前页码
          page_count: 0, //总页数
          page_size: 10, //每页数量
          total_count: 0 //总数量
        };
        return;
      }
      this.tableData = data.list;
      this.pagination = data.pagination;
      this.download_url = data.download_url;
    },
    reset() {
      this.form.enterprise_sn = "";
      this.form.keys = "";
      this.form.enterprise_status = null;
      this.form.create_time = [];
      this.query();
    },
    exportList() {
      this.$import_excal(this.download_url || "");
      console.log("exxport_list");
    }
  },
  created() {}
};
</script>


<style lang="less" :scope="true"  src="@/style/businessManagement/facilitator_enterprise_sign.less" >
</style>